//
//  ABCell.m
//  ZhiBoYuan
//
//  Created by apple on 2018/4/16.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ABCell.h"
#import "MicroCourseModel.h"
#import "UIImageView+WebCache.h"

@implementation ABCell

- (void)setMicroModel:(MicroCourseModel *)microModel{
    _microModel = microModel;
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:microModel.image_url] placeholderImage:[UIImage imageNamed:@"lessonPlace"]];
    self.titleLabel.text = microModel.name;
    self.browseNum.text = [NSString stringWithFormat:@"学习人数:%@",microModel.view_num];
    self.teacherLabel.text = [NSString stringWithFormat:@"主讲老师:%@",microModel.teacher_name];
    
    
    
    if ([microModel.is_free intValue] == 1) {
        self.freeLabel.text = @"免费";
        self.freeLabel.layer.borderWidth = 0;
        self.freeLabel.font = [UIFont systemFontOfSize:17];
        self.freeLabel.textColor = [UIColor greenColor];
        self.priceNum.hidden = YES;
        self.freeLabel.edgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    }else{
        self.freeLabel.text = @"平台使用费";
        self.freeLabel.layer.borderWidth = 1;
        self.freeLabel.textColor = [UIColor redColor];
        self.freeLabel.font = [UIFont systemFontOfSize:15];
        self.freeLabel.layer.borderColor = [[UIColor redColor] CGColor];
        self.priceNum.hidden = NO;
        self.priceNum.text = [NSString stringWithFormat:@"%@学豆",microModel.price];
        self.freeLabel.edgeInsets = UIEdgeInsetsMake(4, 4, 4, 4);
    }
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    _height.constant = HeightConfig(80);
    
    _width.constant  =  _height.constant/9*16;
    
    _typeLabel.layer.borderWidth = 1;
    _typeLabel.layer.borderColor = [UIColor redColor].CGColor;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
